/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Delta;

import Domain.MateriaalSoort;
import Draw.ColorSet;
import Exceptions.BelowOrEqualsToZeroException;
import Exceptions.ValueNotBetweenZeroAndOneException;
import Jama.Matrix;
import java.awt.Color;

/**
 *
 * @author Ahmet
 */
public class Lamel {

    private int id;
    
    private double El;
    private double Et;
    private double Mult;
    private double Glt;
    private double rhol;
    private double Mutl;
    private double alphaL;
    private double alphaT;
    private Fiber myFiber;
    private Epoxy myEpoxy;
    private double vf;
    
    private String name;
    private String manufacturer;
    private Color color;
    
    private double angle; //hoek
    private double thickness; //dikte
    private boolean prepreg;
    private ColorSet colorSet;
    private MateriaalSoort type;
    
    //Stijfheidsmatrix (qmat)
    private Matrix Q1;
    //Thermische uitzettings(alpha)matrix (3x1)
    private Matrix QA;

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public double getEl() {
        return El;
    }

    public void setEl(double El) {
        this.El = El;
    }

    public double getEt() {
        return Et;
    }

    public void setEt(double Et) {
        this.Et = Et;
    }

    public double getGlt() {
        return Glt;
    }

    public void setGlt(double Glt) {
        this.Glt = Glt;
    }

    public double getMult() {
        return Mult;
    }

    public void setMult(double Mult) {
        this.Mult = Mult;
    }

    public double getMutl() {
        return Mutl;
    }

    public void setMutl(double Mutl) {
        this.Mutl = Mutl;
    }

    public double getAlphaL() {
        return alphaL;
    }

    public void setAlphaL(double alphaL) {
        this.alphaL = alphaL;
    }

    public double getAlphaT() {
        return alphaT;
    }

    public void setAlphaT(double alphaT) {
        this.alphaT = alphaT;
    }

    public Epoxy getMyEpoxy() {
        return myEpoxy;
    }

    public void setMyEpoxy(Epoxy myEpoxy) {
        this.myEpoxy = myEpoxy;
    }

    public Fiber getMyFiber() {
        return myFiber;
    }

    public void setMyFiber(Fiber myFiber) {
        this.myFiber = myFiber;
    }

    public double getRhol() {
        return rhol;
    }

    public void setRhol(double rhol) {
        this.rhol = rhol;
    }

    public double getVf() {
        return vf;
    }

    public void setVf(double vf) {
        this.vf = vf;
    }

    public Color getColor() {
        return color;
    }

    public void setColor(Color color) {
        this.color = color;
    }

    public double getAngle() {
        return angle;
    }

    public void setAngle(double angle) {
        this.angle = angle;
    }

    public boolean isPrepreg() {
        return prepreg;
    }

    public void setPrepreg(boolean prepreg) {
        this.prepreg = prepreg;
    }

    public double getThickness() {
        return thickness;
    }

    public void setThickness(double thickness) {
        this.thickness = thickness;
    }

    public ColorSet getColorSet() {
        return colorSet;
    }

    public void setColorSet(ColorSet colorSet) {
        this.colorSet = colorSet;
    }

    public MateriaalSoort getType() {
        return type;
    }

    public void setType(MateriaalSoort type) {
        this.type = type;
    }
    
    public String getManufacturer() {
        return manufacturer;
    }

    public void setManufacturer(String manufacturer) {
        this.manufacturer = manufacturer;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
    
    public Matrix getQ1() {
        return Q1;
    }

    public void setQ1(Matrix Q1) {
        this.Q1 = Q1;
    }
    
    public Matrix getQA() {
        return QA;
    }
    
    public void setQA(Matrix QA) {
        this.QA = QA;
    }
    
    /**
     * Maakt een {@code Lamel} aan de hand van een {@code Fiber}, {@code Epoxy} en volumefractie.
     * @param fiber De fiber (vezel) waaruit de {@code Lamel} zal gaan bestaan.
     * @param epoxy De epoxy (matrix/lijm) waaruit de {@code Lamel} zal gaan bestaan.
     * @param vf Volumefractie
     * 
     * @return de {@code Lamel} die is aangemaakt
     */
    public Lamel(Fiber fiber, Epoxy epoxy, double vf) throws ValueNotBetweenZeroAndOneException {
        
        if (vf >= 1 || vf <= 0) {
            throw new ValueNotBetweenZeroAndOneException();
        }
        Lamel l = Reken.tclaml(fiber, epoxy, vf);
        this.El = l.El;
        this.Et = l.Et;
        this.Mult = l.Mult;
        this.Glt = l.Glt;
        this.rhol = l.rhol;
        this.Mutl = l.Mutl;
        this.alphaL = l.alphaL;
        this.alphaT = l.alphaT;
        this.myFiber = fiber;
        this.myEpoxy = epoxy;
        
        calculateQ1();
        calculateQA();
    }
    
    
    
    /**
     * Maakt een {@code Lamel} aan de hand van de variabelen
     * @param El Elasticiteitsmodulus lengte
     * @param Et Elasticiteitsmodulus breedte
     * @param Mult Dwarscontractiecoëfficiënt
     * @param Glt Glijdingsmodulus
     * @param rhol Dichtheid
     * @param Mutl Dwarscontractiecoëfficiënt (0 om automatisch te laten berekenen)
     * @param alphaL thermische uitzetting lengte (optioneel, 0 voor leeg)
     * @param alphaT thermische uitzetting lengte (optioneel, 0 voor leeg)
     */
    public Lamel(String name, double El, double Et, double Mult, double Glt, double rhol, double alphaL, double alphaT, double thickness, ColorSet colorset) throws BelowOrEqualsToZeroException {
        
        if (thickness <= 0)
            throw new BelowOrEqualsToZeroException();
        
        this.El = El;
        this.Et = Et;
        this.Mult = Mult;
        this.Glt = Glt;
        this.rhol = rhol;
        this.Mutl = obtainMutl(Mult, El, Et);
        this.alphaL = alphaL==0? null : alphaL;
        this.alphaT = alphaT==0? null : alphaT;
        this.thickness = thickness;
        this.prepreg = true;
        this.colorSet = colorset;
        calculateQ1();
        calculateQA();
    }
    
    public Lamel(double El, double Et, double Mult, double Glt, double rhol, double alphaL, double alphaT){
        this.El = El;
        this.Et = Et;
        this.Mult = Mult;
        this.Glt = Glt;
        this.rhol = rhol;
        this.Mutl = obtainMutl(Mult, El, Et);
        this.alphaL = alphaL==0? null : alphaL;
        this.alphaT = alphaT==0? null : alphaT;
    }
    
    public Lamel makeLamel(Fiber f, Epoxy e, double vf) {
        return Reken.tclaml(f, e, vf);
    }

    @Override
    public String toString() {
        //return "Lamel{" + "El=" + El + ", Et=" + Et + ", Mult=" + Mult + ", Glt=" + Glt + ", rhol=" + rhol + '}';
        return name;
    }
    
    private double obtainMutl(double Mult, double El, double Et)
    {
        return Reken.makeMutl(Mult, El, Et);
    }
    
    private void calculateQ1()
    {
        this.Q1 = Reken.qmat(this);
    }
    
    private void calculateQA()
    {
        this.QA = Reken.Qa(alphaL,alphaT,0);
    }
    
    
}
